<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>开始使用layui</title>
  <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>
 
<!-- 你的HTML代码 -->
 
<script src="../layui/layui.js"></script>
<script>

// 增加数据
layui.data('test', {
  key: 'nickname'
  ,value: '贤心'
});


var localTest = layui.data('test');
console.log(localTest.nickname); //获得“贤心”

//  修改 等于  覆盖  添加
layui.data('test', {
  key: 'nickname'
  ,value: '李明'
});


var localTest = layui.data('test');
console.log(localTest.nickname);  //获得“李明'”

//  删除
layui.data('test', {
  key: 'nickname'
  ,remove: true
});


var localTest = layui.data('test');
console.log(localTest.nickname);  //空值 undefined

// 删除 2
layui.data("test",null);

var localTest = layui.data('test');
console.log(localTest.nickname);  //空值 undefined

</script> 
</body>
</html>
